package com.intellagric.controller.portal.traceability;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.traceability.ProduceVo;
import com.intellagric.pojo.TraceProduce;
import com.intellagric.service.traceability.trace_produce.ProduceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/11/3
 * @DESC： 溯源模块农产品信息管理
 */
@Controller
public class ProduceController {

    @Autowired
    private ProduceService produceService;

    /**
     * 查询农产品信息
     * @return TraceProduce
     */
    @RequestMapping("/produce/{id}")
    @ResponseBody
    public TraceProduce get(@PathVariable String id) {
        return produceService.getProductById(id);
    }

    /**
     * 查询农产品信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return produceService.getProductList();
    }

    /**
     * 分页查询农产品信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/pageByCreateBy")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit,String createBy) {
        System.out.println("createBy"+createBy);
        return produceService.getProductPage(page,limit,createBy);
    }

    /**
     * 分页查询农产品信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/page")
    @ResponseBody
    public LayuiDataGridResult getPage(int page,int limit) {
        return produceService.getProductPage(page,limit);
    }

    /**
     * 多条件查询农产品信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/produce/query")
    @ResponseBody
    public LayuiDataGridResult getQueryList(ProduceVo produceVo) {
        return produceService.getProductByVo(produceVo);
    }
}
